<div class="row">
    <div class="col-md-12">
        <div class="portlet">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-sitemap"></i>
                    <strong><?=__('Roles Setting')?></strong>
                </div>
                <div class="actions">
                    <a data-toggle="modal" href="<?=url('role/modal')?>" data-target="#ajax-modal" class="btn default yellow-stripe">
                        <i class="fa fa-plus"></i>
                        <?=__('Add Role')?>
                    </a>
                </div>
            </div>
            <div class="portlet-body">
                <? if (count($roles) == 0): ?>
                <div class="note note-danger">
                    <h4 class="block"><?=__('Sorry !')?></h4>
                    <p>
                        <?=__('No records found!')?>
                    </p>
                </div>
                <? else: ?>
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr class="heading">
                            <th width="60">ID</th>
                            <th><?=__('Description')?></th>
                            <th><?=__('Department')?></th>
                            <th><?=__('Staff')?></th>
                            <th width="60"><?=__('Sort')?></th>
                            <th width="300"><?=__('Actions')?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <? foreach ($roles as $role): ?>
                            <? $userNums = OaUserRoles::count('role_id=' . $role['role_id']); ?>
                            <tr>
                                <td><?=$role['role_id']?></td>
                                <td>
                                    <?=db_translate($role['description'], 'role', $role['role_id'])?>
                                    <? if ($role['protected']): ?>
                                        <i class="fa fa-lock icon-info"></i>
                                    <? endif; ?>
                                </td>
                                <td>
                                    <?=on($role['dept_id'], OaDepartments::path2name($role['department']['depth_path'], ' / '), '-')?>
                                </td>
                                <td><?=on($userNums, $userNums, '-')?></td>
                                <td><?=$role['sort_order']?></td>
                                <td>
                                    <a data-toggle="modal" href="<?=url('role/modal/'.$role['role_id'])?>" data-target="#ajax-modal" class="btn btn-xs default">
                                        <i class="fa fa-pencil"></i> <?=__('Edit')?>
                                    </a>
                                    <a href="<?=url('user/list')?>?role_id=<?=$role['role_id']?>" class="btn btn-xs default">
                                        <i class="fa fa-user"></i> <?=__('Staff')?>
                                    </a>
                                    <a href="#" class="btn btn-xs default">
                                        <i class="fa fa-unlock"></i> <?=__('Permit')?>
                                    </a>
                                    <? if ($role['protected']): ?>
                                        <a href="<?=url('role/delete/'.$role['role_id'])?>" class="btn btn-xs default ajax-delete">
                                            <i class="fa fa-trash-o"></i> <?=__('Delete')?>
                                        </a>
                                    <? endif; ?>
                                </td>
                            </tr>
                        <? endforeach; ?>
                    </tbody>
                </table>
                <? endif; ?>
            </div>
        </div>
    </div>
</div>
